package com.example.shopp_2301.room

import android.app.Application
import androidx.room.Room

/**
 * 数据库工具类，封装初始化方法、封装对外暴露数据库方法
 */
class AppDbUtils {
    companion object{
        //私有化定义数据库
        private lateinit var appDb: AppDb

        //初始化
        fun init(application: Application){
            appDb = Room.databaseBuilder(application,AppDb::class.java,"2301.db")
                .allowMainThreadQueries()
                .build()
        }
        //对外暴露数据库
        fun getDb() = appDb
    }
}